//
//  IDepartment.m
//  XRmenu
//
//  Created by yangxh on 11-3-28.
//  Copyright 2011年 E0571. All rights reserved.
//

#import "IDepartment.h"


@implementation IDepartment
@synthesize brife;
@synthesize departmentId;
@synthesize name;

//=========================================================== 
// - (id)init
//
//=========================================================== 
- (id)init
{
    return [self initWithBrife:nil departmentId:nil name:nil];
}


//=========================================================== 
// - (id)initWith:
//
//=========================================================== 
- (id)initWithBrife:(NSString*)aBrife departmentId:(NSString*)aDepartmentId name:(NSString*)aName 
{
    self = [super init];
    if (self) {
        self.brife = aBrife;
        self.departmentId = aDepartmentId;
        self.name = aName;
    }
    return self;
}


//=========================================================== 
// + (id)objectWith:
//
//=========================================================== 
+ (id)objectWithBrife:(NSString*)aBrife departmentId:(NSString*)aDepartmentId name:(NSString*)aName  
{
    id result = [[[self class] alloc] initWithBrife:aBrife departmentId:aDepartmentId name:aName];
    
    return [result autorelease];
}

//=========================================================== 
// - (NSArray *)keyPaths
//
//=========================================================== 
- (NSArray *)keyPaths
{
    NSArray *result = [NSArray arrayWithObjects:
                       @"brife",
                       @"departmentId",
                       @"name",
                       nil];
    
    return result;
}


//=========================================================== 
// - (NSString *)descriptionForKeyPaths
//
//=========================================================== 
- (NSString *)descriptionForKeyPaths 
{
    NSMutableString *desc = [NSMutableString string];
    NSEnumerator *e = [[self keyPaths] objectEnumerator];
    NSString *thisKey;
    [desc appendString:@"\n\n"];
    
    while ((thisKey = [e nextObject])) {
        [desc appendFormat: @"%@: %@\n", thisKey, [self valueForKey:thisKey]];
    }
    
    return [NSString stringWithString:desc];
}

- (NSString *)description
{
    return [self descriptionForKeyPaths];
}

//=========================================================== 
// dealloc
//=========================================================== 
- (void)dealloc
{
    [brife release];
    brife = nil;
    [departmentId release];
    departmentId = nil;
    [name release];
    name = nil;
    
    [super dealloc];
}

+ (IDepartment *)iDepartmentByParse:(NSDictionary *)info
{
    IDepartment *dept = [IDepartment objectWithBrife:dictObject(info, @"Brief") departmentId:dictObject(info, @"DepartmentId") name:dictObject(info, @"Name")];
    return dept;
}

@end
